﻿using DingChiServiceApp.helper;
using DingChiServiceApp.service;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.ServiceProcess;
using System.Threading.Tasks;
using System.Windows;

namespace DingChiServiceApp
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            if(e.Args != null &&e.Args.Length >0 && e.Args[0].Equals("service"))
            {
                string param = e.Args[0];
                try
                {
                    ServiceBase[] serviceToRun = new ServiceBase[] { new DingChiService() };
                    ServiceBase.Run(serviceToRun);
                }
                catch (Exception ex)
                {
                    var m = "Service Start Error：" + DateTime.Now.ToString() + "\n" + ex.Message;
                    LogHelper.FileLog(m);                  
                }
            }
            new MainWindow().Show();
        }
    }
}
